<template>
  <div class="home">
    <div class="bg"></div>
    <h1>你画我猜</h1>
    <div class="game_list">
      <div class="item" @click="singleDraw">🎨 画一幅画让朋友猜</div>
      <div class="item" @click="createGame">👫 建房间和朋友联机对战</div>
      <div class="item">😎 晒图大会</div>
      <div class="item">🏩 加微信群玩</div>
      <div class="item">💅 关注二店长哟</div>
    </div>
    <div class="ba"></div>
  </div>
</template>

<script>
import Socket from "@/util/Socket.js";
export default {
  methods: {
    singleDraw(){
      this.$router.push({path:"/singleDraw"});
    },
    createGame() {
      Socket.addLisener("game_created", serverData => {
        this.gameCreated(serverData.gameId);
      });
      let data = { op: "create_game" };
      Socket.send(JSON.stringify(data));
      
    },
    gameCreated(gameId) {
      this.$router.push({path:"/game",query:{gameId}});
    }
  },
  mounted() {}
};
</script>

<style scoped>
.bg {
  position: fixed;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #00a8db;
  z-index: -1;
}
h1 {
  text-align: center;
  font-size: 30px;
  font-weight: bold;
  color: #ff9088;
  margin: 50px 0 20px 0;
  text-shadow: 2px 3px 0px #5a88bb;
}

.game_list {
  padding: 50px;
}

.item {
  margin: 20px 0;
  color: #fff;
  font-size: 18px;
  text-align: left;
  cursor: pointer;
}

.item:hover {
  text-shadow: 0 0 5px;
}
</style>
